/**
 * 展会活动详情
 */
import db from "../../db";
export default defineEventHandler(async (event) => {
  const { n_id } = getQuery(event);
  if (!Number(n_id)) {
    return {
      code: -1,
      message: "参数错误: n_id",
      data: null,
    };
  }
  try {
    const sql = `SELECT event_id,title,cover,content,view_count,create_time,update_time FROM exhibition_event where event_id=?`
    const [rows] = await db.query(sql, [n_id]);
    const res = (rows as any[])[0];
    return {
      code: 1,
      message: "成功",
      data: res,
    };
  } catch (error) {
    console.error(error);
    return {
      code: 500,
      message: "服务器错误",
      data: null,
    };
  }
});
